 % Copyright (C) 2012 	Paul Bovbel, paul@bovbel.com
 % 						Richard Abrich, abrichr@gmail.com
 %
 % This file is part our empirical study of boosting algorithms (http://code.google.com/p/boosting-study/)
 % 
 % This is free software; you can redistribute it and/or modify
 % it under the terms of the GNU General Public License as published by
 % the Free Software Foundation; either version 3 of the License, or
 % (at your option) any later version.
 % 
 % This source code is distributed in the hope that it will be useful,
 % but WITHOUT ANY WARRANTY; without even the implied warranty of
 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 % GNU General Public License for more details.
 % 
 % You should have received a copy of the GNU General Public License
 % along with this source code. If not, see http://www.gnu.org/licenses/

clear;

%generate toy dataset

data(1) = 0;

%number of datapoints
N = 10000;

%test/train split
split = 0.3;

%form of datapoint i: [class continuous_feature categorical_feature]
for i=1:N
    if i < N/2
        data(i,1) = 0;          % class
        data(i,2) = 2*randn+1;    % continuous feature
        data(i,3) = 2*randn-1;
    else
        data(i,1) = 1;        
        data(i,2) = 2*randn-1;
        data(i,3) = 2*randn+1;
    end
    
    
    if i < N*1/3
        data(i,4) = 1;          % discrete feature (1, 2, 3)
    elseif i < N*2/3
        data(i,4) = 2;
    else
        data(i,4) = 3;
    end
    
    if i < N*3/5
        data(i,5) = 1;          % discrete feature (1, 2, 3)
    elseif i < N*4/5
        data(i,5) = 2;
    else
        data(i,5) = 3;
    end
    
    data(i,6) = randi(2);      % uncorrelated discrete feature
    data(i,7) = rand;           % uncorrelated continuous feature
    
end

shuffle = randperm(N);                          %shuffle the data
data_shuffled = data(shuffle,:);

train_data = data_shuffled(1:ceil(N*split),:);        %split the data
test_data = data_shuffled(ceil(N*split)+1:N,:);

figure(1)
scatter(data(:,2),data(:,3),1,data(:,1))
save('..\res\toy.mat', 'data', 'test_data', 'train_data');